<?php namespace App\Http\Controllers;

use App\Answers;
use App\Page;
use App\Plan;
use App\PlanJoin;
use App\Profession;
use App\Questions;
use App\User;
use App\UserInfo;
use App\VisitLog;
use Illuminate\Contracts\Auth\Guard;
use Auth;
use Illuminate\Http\Request;

class AdminController extends Controller
{
    public function login(){
        return view('admin.login');
    }

    public function questionList(){

        $allQuestions = Questions::orderBy('id','desc')->get();
        if(count($allQuestions) > 0){
            foreach ($allQuestions as $question){
                $allAnswers = Answers::whereQid($question->id)->orderBy('select_num','asc')->get();
                $question->answers = $allAnswers;
            }
        }
        return view('admin.question-list',['questions'=>$allQuestions]);
    }

    public function questionAdd(){
        return view('admin.question-add');
    }

}